import java.util.ArrayList;

import algorithm.algorithm;
import structure.*;


public class Main {

	public static void main(String[] args) {
		
		String grammar= "S->CC;C->cC;C->d.";
		//"S->AB;A->aA|a;B->bB|e.";//"S->aAb|SA;A->aA|e|S.";//"S->A|a;A->e.";//"S->e|A|ab|AB;A->BB|e|aBb;B->Ab|aB|b.";
		//"S->A;A->e.";//"S->aA;A->B|CDC;B->e|a;C->B|D;D->e|b.";//"S->AS|A;A->a|B;B->b|S|A.";
		//"E->E+T|TxF|(E)|a;T->TxF|(E)|a;F->(E)|a.";
		////"S->aA|bB;A->e|cAd;B->e.";//"S->SSA|e;A->AAa|e|AB;B->b|bB|A.";
		//"E->E+T|T;T->TxF|F;F->(E)|a.";//"S->SSA|e;A->C|AAa|e|AB;B->b|bB|A;C->A|c.";
		//"S->CC;C->cC;C->d.";"dcd$";//"A->BA;A->e;B->aB;B->b.";"aabb$";
		//"E->E+T|T;T->T*a|a.";"a*a+a$";//"S->BBa;B->Bb|c.";//"ccbbba$";
		//"S->aA|bB;A->e|cAc;B->e.";
		grammar g= new grammar(grammar);
		System.out.println("La grammatica data è: ");
		System.out.println(grammar);
		g.printItAll();
		System.out.println("Dopo le procedure di semplificazione: ");

		g= algorithm.FromBelowProcedure(g);
		g= algorithm.FromAboveProcedure(g);
		g.printItAll();
		String w= "";
		System.out.println("La word in input è: " + w);

		System.out.println("");
		System.out.println("La grammatica enumerata è: ");
		enumerateGrammar e= new enumerateGrammar(g);
		e.printItAll();
		/*
		graph graph= new graph(e);
		for(item[] s :graph.getConnectionInterBP()){
			System.out.println("item[0]: ");
			s[0].printItAll();
			System.out.println("item[1]: ");
			s[1].printItAll();
		}*/
		System.out.println("");
		powerset powerset= new powerset(e);
		
		powerset.printItAll();
		
		parsingTable pT= new parsingTable(powerset);
		pT.printItAll();
		
		//parser parser= new parser(pT, w);
		
		///parser.parsing();
		
		//ArrayList<String> first= algorithm.First1(e, "+T", null, null);
		//System.out.println("first= " + first);
	}

}
